Page({
    data: {
        imagePath: '',
        imageSize: 0,
        avatarUrl: ''
    },
    async chooseImage() {
        const res = await wx.chooseMedia({
            count: 1,
            mediaType: ['image']
        })
        // console.log(res)
        if (res.tempFiles.length > 0) {
            this.setData({
                imagePath: res.tempFiles[0].tempFilePath,
                imageSize: res.tempFiles[0].size
                
            })
            wx.setStorageSync('imagePath',res.tempFiles[0].tempFilePath)

        }

    },
    onchooseAvatar(event: WechatMiniprogram.CustomEvent) {
        // console.log(event)
        this.setData({
            avatarUrl: event.detail.avatarUrl,
        })
        wx.setStorageSync('avatarUrl',event.detail.avatarUrl)

    },
    saveData() {
        wx.setStorageSync('list', ['烤冷面', '手抓饼', '煎饼果子'])
        wx.showToast({ title: '保存成功！' })
    },
    getData() {
        const list = wx.getStorageSync('list')
        wx.showToast({ title: JSON.stringify(list), icon: 'error' })
    },
    removeData() {
        wx.removeStorageSync('list')
        wx.showToast({ title: '删除成功！' })
    },
    clearData() {
        wx.clearStorageSync()
        wx.showToast({ title: '清除成功！' })
    },
})